using UnityEngine;
using System.Collections;


public class MainMenu : Menu
{
	public Transform audioPrefab;
	
	void Start()
	{		
		base._manager = gameObject.GetComponent<MenuManager>();
		base.amount = _manager.amount;
	
		beginNavigationY(limit,yieldReturnControls);
		
		if(GameObject.Find("AudioBehavior"))
			Destroy(GameObject.Find("AudioBehavior"));
		
		effectSwitch(0);

	}
		
	void Update()
	{			
		if(base.ready && Input.GetAxisRaw("Vertical") != 0)
		{
			base.navigationY();
			this.effectSwitch(actualNavigationPosY);
		}
		
		if(base.ready && base.hasPressEnter())
		{
			this.executeAction(actualNavigationPosY);
		}
				
	}
	
	public override void effectSwitch(int number)
	{
		if(number != lastNumberY)
		{
			this.effectSwitchFlashColors(this.actualNavigationPosY,this.lastNumberY);
		}
		else if(!ready)
		{
			this.effectSwitchFlashColors(this.actualNavigationPosY,this.lastNumberY);
		}
	}
	
	public override void executeAction(int number)
	{	
		if(number == 0)
		{
			if(PlayerPrefs.GetString("Tutorial").Equals("Off"))
				_manager.changeScene("Selecao");
				
			else
			{
				Transform a = Instantiate(audioPrefab,Camera.mainCamera.transform.position,Camera.mainCamera.transform.rotation) as Transform;
				a.name = "AudioBehavior";
				_manager.changeScene("Tutorial");
			}
		}	
		
		if(number == 1)
		{
			_manager.changeScene(this.menuElements[number].name);
		}
		
		if(number == 2)
		{
			_manager.changeScene(this.menuElements[number].name);
		}
	}
	
	void Ready()
	{
		base.ready = true;
	}
	
}
